package expriment4_T7;

public class Student {
    public String name;
    public int age;
    private String sex;

    public Student() {
    }

    public Student(String name, int age, String sex) {
        this.name = name;
        this.age = age;
        this.sex = sex;
    }

    public String getSex() {
        return sex;
    }

    @Override
    public String toString() {
        return "Student [ name=" + name + ','+
                "age=" + age +','+
                "sex=" + sex + "]";
    }

    public void setSex(String sex) {
        this.sex = sex;
    }
    public void showInfo(){
        System.out.println("姓名：" + name + '\n'+ "年龄：" + age +'\n'+ "性别：" + sex );
    }
}
class StudentDemo{
    public static void main(String[] args) {
        System.out.println("无参函数，用showinfo（）");
        Student s1 = new Student();
        s1.name="贾玲";
        s1.age=21;
        s1.setSex("女");
        s1.showInfo();
        System.out.println("-------------------------");
        Student s2 = new Student("岳云鹏",26,"男");
        System.out.println(s2);
    }
}
